$SAVE
$NOLIST
;************************************************************************
;*									*
;*    R T X - 51  :  INTERRUPT MASK HANDLING MACROS                     *
;*							     		*
;*----------------------------------------------------------------------*
;*                                                                      *
;*    Filename     :   RTXIMASK.INC                                     *
;*    Language     :   Keil A-51                                        *
;*    Dev. system  :   Keil uVision2                                    *
;*    Targetsystem :   Any system based upon 8051 up                    *
;*                                                                      *
;*    Purpose      :   Macro definitions for interrupt mask handling.   *
;*                     To be used as an include file.                   *
;*								     	*
;*----------------------------------------------------------------------*
;* Rev. |  Released   | Programmer    | Comments                        *
;*----------------------------------------------------------------------*
;*  0.1 |   4.1.90    | E. Glatz      | File created                    *
;*  0.2 |   7.4.91    | Th. Fischler  | Adapted to Keil A-51            *
;*      |   3.5.91    |               | global_int_disable and          *
;*      |             |               | global_int_enable added         *
;*  0.3 |  18.11.91   | Th. Fischler  | access IE-Reg's un-interrupted  *
;* 7.00 |  13.11.2001 | T. Mueller    | Release 7.00                    *
;************************************************************************
;*    Copyright 1991 .. 2001 METTLER  &  FUCHS  AG,  CH-8953 Dietikon   *
;************************************************************************


RTX_ALLOW_INT  MACRO
               LOCAL DONE, ONE, TWO
;;
;;      Allow Task Interrupts
;;      ---------------------
;;      All RTX interrupts are enabled when running task is a non driver.
;;      When running task is a driver, then no RTX interrupts are enabled.
;;
;;
               JB    ?RTX_RUNNING_TID.4, DONE    ; If a driver is running:
                                                 ; do NOT enable int's

               JNB   ?RTX_ENA_INT_REG1, ONE  ; Check for 2. interrupt register
               JNB   ?RTX_ENA_INT_REG2, TWO  ; Check for 3. interrupt register
               MOV   ?RTX_IEN2, ?RTX_ND_IE2
TWO:           MOV   ?RTX_IEN1, ?RTX_ND_IE1
ONE:           MOV   ?RTX_IE, ?RTX_ND_IE
DONE:
               DBG_UNLOCK_DRV
               ENDM




RTX_ALLOW_DRV_INT  MACRO
                   LOCAL DONE, ONE, TWO
;;
;;      Allow Driver Task Interrupts
;;      ----------------------------
;;      Driver task interrupts are enabled when running task is a non driver.
;;      When running task is a driver, then no RTX interrupts are enabled.
;;
;;      To be used to create windows for driver tasks inside of system
;;      functions. To close the window: use the EXCLUDE_INT macro.
;;
               JB    ?RTX_RUNNING_TID.4, DONE    ; If a driver is running:
                                                 ; do NOT enable int's
               JNB   ?RTX_ENA_INT_REG1, ONE  ; Check for 2. interrupt register
               JNB   ?RTX_ENA_INT_REG2, TWO  ; Check for 3. interrupt register
               MOV   ?RTX_IEN2, ?RTX_D_IE2
TWO:           MOV   ?RTX_IEN1, ?RTX_D_IE1
ONE:           MOV   ?RTX_IE, ?RTX_D_IE
DONE:
               DBG_UNLOCK_DRV
               ENDM



RTX_EXCLUDE_INT    MACRO
                   LOCAL DONE, ONE, TWO
;;
;;      Exclude Task Interrupts
;;      -----------------------
;;      Disable all RTX interrupts, only interrupts not assigned to RTX
;;      remain enabled.
;;
               JNB   ?RTX_ENA_INT_REG1, ONE  ; Check for 2. interrupt register
               JNB   ?RTX_ENA_INT_REG2, TWO  ; Check for 3. interrupt register
               MOV   ?RTX_IEN2, ?RTX_NM_IE2
TWO:           MOV   ?RTX_IEN1, ?RTX_NM_IE1
ONE:           MOV   ?RTX_IE, ?RTX_NM_IE
               DBG_LOCK_DRV
               ENDM



GLOBAL_INT_DISABLE    MACRO
;;
;;      Disable all Interrupts
;;      ----------------------
;;
               CLR   ?RTX_IE.7
               ENDM

GLOBAL_INT_ENABLE    MACRO
;;
;;      Enable all Interrupts
;;      ---------------------
;;
;;
               SETB  ?RTX_IE.7
               ENDM

$RESTORE
